<#include "/ftl/front/common/_layout.html"/>
<@html title="JFinal社区 - 找回密码" description="JFinal社区 - 找回密码" sidebar_about="show">
<div class="jf_panel">
    <div class="jf_header">
        <ul class="jf_breadcrumb">
            <li><a href="/">首页</a></li>
            <li class="active">找回密码</li>
        </ul>
    </div>
    <div class="jf_inner">
        <form class="form-horizontal" style="line-height: 1.5em;">
            <input type="hidden" id="code" name="code" value="${code!}">
            <div class="form-group">
                <label for="email" class="col-sm-2 control-label">邮箱</label>
                <div class="col-sm-6">
                    <input type="text" class="form-control" id="email" value="${email!}" disabled="disabled" placeholder="邮箱">
                </div>
            </div>
            <div class="form-group">
                <label for="newPass" class="col-sm-2 control-label">新密码</label>
                <div class="col-sm-6">
                    <input type="password" class="form-control" id="newPass" placeholder="新密码">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="button" id="login" class="btn btn-primary">确定</button>
                </div>
            </div>
        </form>
        <script type="text/javascript">
            $(function() {
                $("#login").click(function(){
                    if($("#newPass").val().trim() == "") {
                        alert("请输入密码");
                    } else {
                        $.ajax({
                            url: "/reset",
                            async: false,
                            cache: false,
                            type: 'post',
                            dataType: "json",
                            data: {
                                code: $("#code").val(),
                                email: $("#email").val(),
                                newPass: $("#newPass").val()
                            },
                            success: function (data) {
                                if (data.code == '200') {
                                    alert(data.detail);
                                    location.href="/login";
                                } else {
                                    alert(data.description);
                                }
                            }
                        });
                    }
                });
            });
        </script>
    </div>
</div>
</@html>